package com.pengtu.service.project;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.dao.Page;
import com.pengtu.dao.QueryFilter;
import com.pengtu.dao.app.OrganizationDao;
import com.pengtu.dao.app.UserDao;
import com.pengtu.dao.project.ProjectInfoDao;
import com.pengtu.dao.project.QualificationDao;
import com.pengtu.entity.app.Organization;
import com.pengtu.entity.app.User;
import com.pengtu.entity.project.ProjectInfo;
import com.pengtu.entity.project.Qualification;

@Transactional
@Component
public class ProjectmassManager {

	private ProjectInfoDao projectinfoDao;
	private UserDao userDao;
	private OrganizationDao organizationDao;
	private QualificationDao qualificationDao;
	
	
	@Autowired
	public void setQualificationDao(QualificationDao qualificationDao) {
		this.qualificationDao = qualificationDao;
	}



	@Autowired
	public void setProjectinfoDao(ProjectInfoDao projectinfoDao) {
		this.projectinfoDao = projectinfoDao;
	}

	@Autowired
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	@Autowired
	public void setOrganizationDao(OrganizationDao organizationDao) {
		this.organizationDao = organizationDao;
	}
	

		
	/**
	 * 根据Id查询工程基本信息
	 * @param id
	 * @return
	 */
	@Transactional(readOnly=true)
	public ProjectInfo getProjById(String id){
		
		return projectinfoDao.get(id);
		
	}
	
	/**
	 * 分页查询全部用户信息
	 * @param page
	 * @param fileter
	 * @return
	 */
	@Transactional(readOnly = true)
	public Page<User> findPageUser(final Page<User> page,final QueryFilter fileter) {

		return userDao.findPage(page, fileter);
	}

	@Transactional(readOnly = true)
	public List<Organization> findOrgan(String propertyName, Object value) {

		return organizationDao.findBy(propertyName, value);
	}
	
	/**
	 * 根据orgId查询单位资质信息
	 * @param orgId
	 * @return
	 */
	public Qualification getQualificationByorgId(String id){
		
		return qualificationDao.findUniqueBy("orgId", id);
	}
	
//	public List<Organization> findOrganAll(String projectId,String value){
//		String hql="select ot from Organization as ot where ot.projectId=? and ot.";
//		return organizationDao.find(hql, values)
//	}
	 
}
